import React, { useEffect, useState } from 'react'
import { FlatList, StyleSheet, TouchableOpacity, Text, Button, View, Image, ImageBackground, ScrollView, Dimensions } from 'react-native';
import { Entypo } from '@expo/vector-icons';
import axios from '../../api/axios';
import { useAuth, baseURL } from '../../context/AuthProvider';
const add = (m) => { return m < 10 ? '0' + m : m }
//将时间戳转为普通格式
const fortime = (shijianchuo) => {
    var time = new Date(shijianchuo);
    var y = time.getFullYear();
    var m = time.getMonth() + 1;
    var d = time.getDate();
    var h = time.getHours();
    var mm = time.getMinutes();
    var s = time.getSeconds();
    return y + '-' + add(m) + '-' + add(d) + ' ' + add(h) + ':' + add(mm) + ':' + add(s);
}
const Detail = ({ navigation }) => {
    const { navigate } = navigation;
    const { user } = useAuth()
    const [coinlist, setCoinlist] = useState([])
    useEffect(() => {
        axios.post('/coin/getcoin', { userid: user.userid }).then(res => {
            console.log(res.data);
            setCoinlist(res.data)
        })
    },[])
    return <ScrollView style={styles.con}>
        {
            coinlist.map(item => {
                return <View style={styles.minicon}>
                    <View style={styles.leftcon}>
                        <Text>{item.type==0?'每日签到奖励':(item.type==1?'累计签到奖励': "兑换花盆")}</Text>
                        <Text style={{ color: '#BBBBBB', fontSize: 12, marginTop: 2 }}>{item.date}</Text>
                    </View>
                    <Text style={{ color: '#7BCBB8', fontSize: 17 }}>{item.type==2? '-' : '+'}{item.type==0?5:(item.type==1?15:200)}</Text>
                </View>
            })
        }

        <View style={{height: 50}}></View>
    </ScrollView>
}
const styles = StyleSheet.create({
    con: {
        padding: '4%',
        backgroundColor: '#fff',
        height: '100%'
    },
    minicon: {
        borderBottomWidth: 1,
        borderBottomColor: '#BBBBBB',
        alignItems: 'center',
        flexDirection: 'row',
        justifyContent: 'space-between',
        padding: 5
    },
    leftcon: {
        // alignItems: 'center'
    }
})
export default Detail